namespace SimpleWebServices.Xml
{
    using System;

    public sealed class XmlNamespace : ValueObject<XmlNamespace>
    {
        private string _prefix;
        private AbsoluteUri _uri;

        public XmlNamespace(string prefix, AbsoluteUri uri)
            : this()
        {
            this.Prefix = prefix;
            this.Uri = uri;
        }

        private XmlNamespace()
        {
            this.RegisterProperty(x => x.Prefix);
            this.RegisterProperty(x => x.Uri);
        }

        public string Prefix
        {
            get
            {
                return this._prefix;
            }

            set
            {
                if (null == value)
                {
                    throw new ArgumentNullException("value");
                }
                else if (0 == value.Length)
                {
                    throw new ArgumentOutOfRangeException("value");
                }

                this._prefix = value;
            }
        }

        public AbsoluteUri Uri
        {
            get
            {
                return this._uri;
            }

            set
            {
                if (null == value)
                {
                    throw new ArgumentNullException("value");
                }

                this._uri = value;
            }
        }
    }
}